package com.oracle.controller;


import com.oracle.service.BGCLogService;
import com.oracle.service.imp.BGCLogServiceimp;
import com.oracle.service.imp.RabbitmqService;
import com.oracle.vo.BGC;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @program: CampusMatching
 * @description:
 * @author: zhaolei
 * @create: 2020-08-04 10:38
 **/
@Controller
@RequestMapping("/log")
public class receivehandler {

    @Autowired
    RabbitmqService rabbitmqService;

    @Autowired
    BGCLogService bgcLogService;




    @GetMapping("/matchlog")
    public String log(Map map){
         List<BGC> bgclist=bgcLogService.selectall();
         map.put("bgclist",bgclist);
         return "logpage";
    }

    @RabbitListener(queues = "bgc.news")
    public void getBook(BGC bgc) {
        System.out.println("收到信息：" + bgc);
        System.out.println("完成微信的推送：" + bgc);
        bgc.setDate(new Date());
        System.out.println(bgc.getDate());
        bgcLogService.insert(bgc);
        System.out.println("一条日志插入成功！");
    }

}
